package com.hinotoyk.testsystem.uitls;

import com.hinotoyk.testsystem.entity.*;
import com.hinotoyk.testsystem.service.QuestionService;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;

public class TestPaperSave {

    private List<SGQuestion> sgList = new ArrayList<>();
    private List<PLQuestion> plList = new ArrayList<>();
    private List<TOFQuestion> tofList = new ArrayList<>();
    private List<FillingQuestion> fillList = new ArrayList<>();
    private List<EssayQuestion> essayList = new ArrayList<>();

    public String getAnswerById(int type, int id){
        if(type == QuestionType.SGQuestion.getType()){
            for(int i = 0; i < sgList.size(); ++i){
                SGQuestion q = sgList.get(i);
                if(q.getSgQuestionId() == id)
                    return q.getAnswer();
            }
        }else if(type == QuestionType.FillingQuestion.getType()){
            for(int i = 0; i < fillList.size(); ++i){
                FillingQuestion q = fillList.get(i);
                if(q.getFillQuestionId() == id)
                    return q.getAnswer();
            }
        }else if(type == QuestionType.EssayQuestion.getType()){
            for(int i = 0; i < essayList.size(); ++i){
                EssayQuestion q = essayList.get(i);
                if(q.getEssayQuestionId() == id)
                    return q.getAnswer();
            }
        }else if(type == QuestionType.PLQuestion.getType()){
            for(int i = 0; i < plList.size(); ++i){
                PLQuestion q = plList.get(i);
                if(q.getPlQuestionId() == id)
                    return q.getAnswer();
            }
        }else if(type == QuestionType.TOFQuestion.getType()){
            for(int i = 0; i < tofList.size(); ++i){
                TOFQuestion q = tofList.get(i);
                if(q.getTofQuestionId() == id)
                    return q.getAnswer();
            }
        }
        return null;
    }

    public List<SGQuestion> getSgList() {
        return sgList;
    }

    public void setSgList(List<SGQuestion> sgList) {
        this.sgList = sgList;
    }

    public List<PLQuestion> getPlList() {
        return plList;
    }

    public void setPlList(List<PLQuestion> plList) {
        this.plList = plList;
    }

    public List<TOFQuestion> getTofList() {
        return tofList;
    }

    public void setTofList(List<TOFQuestion> tofList) {
        this.tofList = tofList;
    }

    public List<FillingQuestion> getFillList() {
        return fillList;
    }

    public void setFillList(List<FillingQuestion> fillList) {
        this.fillList = fillList;
    }

    public List<EssayQuestion> getEssayList() {
        return essayList;
    }

    public void setEssayList(List<EssayQuestion> essayList) {
        this.essayList = essayList;
    }

}
